import * as types from "../types";

const reducer = (
  state = {
    count: 100,
  },
  action
) => {
  switch (action.type) {
      case types.ADD:
      return { ...state, count: state.count + 1 };
    
      case types.ADDNUM:
      return { ...state, count: state.count + action.payload };
    
      case types.REDUCE:
      return { ...state, count: state.count - 1 };
    
      case types.REDUCENUM:
      return { ...state, count: state.count - action.payload };

    default:
      return state;
  }
};

export default reducer;
